package com.review.demo.aopanno;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author xsyz
 * @created 2020-12-27   16:22
 */
@Aspect
@Component
public class UserProxy {
    @Pointcut("execution(* com.review.demo.*.*.*(..))")
    public void aop(){

    }
    @Before(value ="aop()" )
    public void before(JoinPoint joinPoint){

        String name = joinPoint.getSignature().getName();
        System.out.println("before*******************"+name);
    }
    @After("aop()")
    public void after(JoinPoint joinPoint){
        System.out.println("after*************"+joinPoint.getSignature().getName());
    }
    @Around("aop()")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        System.out.println("之前");
        proceedingJoinPoint.proceed();
        System.out.println("之后");

    }
    @AfterThrowing("aop()")
    public void throw1(JoinPoint joinPoint){
        System.out.println("getSignature:"+joinPoint.getSignature());
        System.out.println("getArg:"+joinPoint.getArgs().toString());
        System.out.println("getTarget:"+joinPoint.getTarget());
    }

}
